﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using LCARSLibrary.Controls;
using LCARSLibrary;
using System.IO;

namespace Lab
{
    public partial class FormMI2Screen1 : Form
    {
        Paging<Area, string> paging;

        public FormMI2Screen1()
        {
            InitializeComponent();

            FileInfo fi = new FileInfo("settings.xml");
            List<string> desktopItems = new List<string>(Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory)));
            desktopItems.AddRange(Directory.GetDirectories(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory)));

            desktopItems.AddRange(Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.CommonDesktopDirectory)));
            desktopItems.AddRange(Directory.GetDirectories(Environment.GetFolderPath(Environment.SpecialFolder.CommonDesktopDirectory)));

            paging = new Paging<Area, string>()
            {
                Parent = this,
                Data = desktopItems,
                ControlSize = new Size(200, 35),
                Spacing = new Size(6, 6),
                StartTopLeftPosition = new Point(area104.Left, area104.Top),
                EndBottomRightPosition = new Point(area104.Right, area104.Bottom)
            };

            paging.SetPageDependentControlData += new EventHandler<SetPageDependentControlDataEventArgs<Area, string>>(paging_SetPageDependentControlData);
            paging.PageChanged += new EventHandler<PageChangedEventArgs>(paging_PageChanged);
            paging.InitializeControl += new EventHandler<ControlEventArgs<Area>>(paging_InitializeControl);
            paging.VisibleChanged += new EventHandler(paging_VisibleChanged);
            paging.InitializeControls();
            paging.Show();

            this.Size = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height - 2);

            new FormMI2Screen2().Show(this);
            area2.Flash(true, Colors.Red3);
        }

        void paging_VisibleChanged(object sender, EventArgs e)
        {
        }

        void paging_InitializeControl(object sender, ControlEventArgs<Area> e)
        {
            e.Control.AutoEllipsis = true;
            e.Control.BackColor = System.Drawing.Color.Transparent;
            e.Control.Behaviour = LCARSLibrary.Behaviour.Click;
            e.Control.Margin = new System.Windows.Forms.Padding(3);
            e.Control.RoundCorners = ((LCARSLibrary.Corner)((((LCARSLibrary.Corner.TopLeft | LCARSLibrary.Corner.TopRight) | LCARSLibrary.Corner.BottomLeft) | LCARSLibrary.Corner.BottomRight)));
            e.Control.RoundRadius = 35;
            e.Control.Size = new System.Drawing.Size(200, 35);
            e.Control.SoundEffect = LCARSLibrary.SoundEffect.Beep2;
            e.Control.TextColor = System.Drawing.Color.Empty;
            e.Control.TextPadding = new System.Windows.Forms.Padding(10, 2, 10, 2);
            //e.Control.Padding = new Padding(3, 3, 3, 3);
            //e.Control.Font = new System.Drawing.Font("LCARSGTJ3", 23F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
            //e.Control.Editable = true;
            e.Control.WordWrap = false;
            e.Control.Width = 200;
        }

        void paging_PageChanged(object sender, PageChangedEventArgs e)
        {
        }

        void paging_SetPageDependentControlData(object sender, SetPageDependentControlDataEventArgs<Area, string> e)
        {
            e.Control.Text = Path.GetFileName(e.Data);
        }

        private void area2_Click(object sender, EventArgs e)
        {
            LCARSBase.PlaySoundEffectSync(LCARSLibrary.SoundEffect.Yes2);
            Close();
        }

        private void area96_Click(object sender, EventArgs e)
        {
            paging.GoToPage(paging.CurrentPage - 1);
        }

        private void area97_Click(object sender, EventArgs e)
        {
            paging.GoToPage(paging.CurrentPage + 1);
        }
    }
}
